﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModuleManager.aspx.cs" Inherits="Public_ModuleManager"
    MaintainScrollPositionOnPostback="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>模块管理</title>
    <%--<link href="../../CSS/main.css" rel="stylesheet" type="text/css" />--%>
    <link href="../../CSS/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    div#detailDiv {
      border:0;
      position:absolute;
     }
    div#detailDiv table{
      border:1px solid #5077A0;
      background-color:#EFF7FF;
      position:absolute;
     }
    </style>
    <script language="javascript" type="text/javascript">
     function document.onclick()
    {
    var pointX=event.clientX; 
    var pointY=event.clientY+document.documentElement.scrollTop+10;
    
    document.getElementById("eventX").value = pointX;
    document.getElementById("eventY").value = pointY;
    }
    function SetDetailDivXY(eventx,eventy)
    {
    var divobj = document.getElementById("detailDiv");
    divobj.style.posTop = eventy;
    divobj.style.posLeft = eventx;
    }
    
    //根据所选择的文件自动生成链接
    function toUrlTextBox()
    {           
        //获取值用value
        var filedir = document.getElementById("file_UrlFile").value;  
        var strPath=window.document.location.pathname;   
        var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
               
        //先把fieldir中的\转成/ ,\\中，第一个\是转义,下面是正则表达式g表示全部
        var newfile = filedir.replace(/\\/g,"/");      
        var no = newfile.lastIndexOf(postPath);              
        newfile = newfile.substring(no+postPath.length, newfile.length);
        var urlTextBox = document.getElementById("TextBox_Url");
        
        urlTextBox.value = "~" + newfile; 
        var dirUpcase = urlTextBox.value.toUpperCase(); 
        
        //下面几张表需要写入表名，所以需要把下拉enable来，选择表
        if(dirUpcase.indexOf("COMMONPAGE.ASPX") > 0 || dirUpcase.indexOf("USERMANAGER.ASPX") > 0
            || dirUpcase.indexOf("USERMANAGERDETAILS.ASPX") > 0|| dirUpcase.indexOf("COMMONPAGEDETAILS.ASPX") > 0)
            document.getElementById("DDLCommonPageTab").disabled = false;
        else
            document.getElementById("DDLCommonPageTab").disabled = true;
        
    }
    
    function WriteUrlEnable()
    {  
        document.getElementById("TextBox_Url").disabled=false; 
    }
    
    function DDLSelectChange(obj)
    {       
        var s = "?";
        var txtUrl = document.getElementById("TextBox_Url").value;  
        var strTab;  
        
        if(txtUrl.toUpperCase().indexOf("USERMANAGERDETAILS.ASPX") < 0 && txtUrl.toUpperCase().indexOf("COMMONPAGEDETAILS.ASPX") < 0)        
        {
            var no = txtUrl.toLowerCase().indexOf("table=");
            if(no < 0) //没有，需要添加
            {
                //是否有？了
                if (txtUrl.indexOf("?") >= 0)       
                    s = "&"; 
                txtUrl = txtUrl + s + "table=" + obj.options[obj.selectedIndex].value;      
                document.getElementById("TextBox_Url").value = txtUrl;  
            }   
            else //已经有了，需要修改
            {
                var str1 = txtUrl.substring(0,no+6);
                var str2 = txtUrl.substring(no+6,txtUrl.length);
                //找后半段串是否有&（第一个&）
                var no2 = str2.indexOf("&");
                if(no2 < 0)
                {
                     str1 += obj.options[obj.selectedIndex].value;
                }
                else
                {
                    var str3 = str2.substring(no2, str2.length);
                    str1 = str1 + obj.options[obj.selectedIndex].value + str3;
                }  
                document.getElementById("TextBox_Url").value = str1;
            }
        }
        //USERMANAGERDETAILS.ASPX是详情，用的是：
        // ~/system/user/UserManagerDetails.aspx?tablecode=TAB_USER&cdtion=
        //其中cdtion=必不可少，表示查看自己信息
        else
        {
            var no = txtUrl.toLowerCase().indexOf("tablecode=");
            if(no < 0) //没有，需要添加
            {
                //是否有？了
                if (txtUrl.indexOf("?") >= 0)       
                    s = "&"; 
                txtUrl = txtUrl + s + "tablecode=" + obj.options[obj.selectedIndex].value + "&cdtion=";      
                document.getElementById("TextBox_Url").value = txtUrl;  
            }   
            else //已经有了，需要修改
            {
                var str1 = txtUrl.substring(0,no+10);
                var str2 = txtUrl.substring(no+10,txtUrl.length);
                //找后半段串是否有&（第一个&）
                var no2 = str2.indexOf("&");
                if(no2 < 0)
                {
                     str1 += obj.options[obj.selectedIndex].value;
                }
                else
                {
                    var str3 = str2.substring(no2, str2.length);
                    str1 = str1 + obj.options[obj.selectedIndex].value + str3;
                }  
                document.getElementById("TextBox_Url").value = str1;
            }
        }
    }
</script>
</head>

<body>
    <form id="form1" runat="server">
    <input id="eventX" type="hidden" value="" name="eventX" />
    <input id="eventY" type="hidden" value="" name="eventY" />
       
        <div id="MainContentCommon">
        <%--<div class="tit" id="mcTitle" runat="server" title="testss" visible="false">
                &gt;&gt;&gt;
                <asp:Label ID="lblTabName" runat="server" Visible="False"></asp:Label>
            </div>  
            <br />--%>
            <div id="mcTitle" class="tit">
                &gt;&gt;&gt;模块管理</div>
                <div class="con">
                <div id="QueryDiv">             
                <div><asp:Label  runat="server" Text="输入模块名:"></asp:Label>
            <input type="text" id="QryText" name="QryText" runat="server" />
            <asp:Button ID="btnQueryNormal" runat="server" Text="查 询" Width="91px" CssClass="buttonface iconSearch"
                Style="display: inline" OnClick="Query_ServerClick" />
                <br />
                </div>
                </div>
                </div>
                <div class="con">
                <div id="QueryDiv">
            <table style="table-layout: fixed">
                <tr>
                    <td>
                        <span style="font-family: 宋体, Arial, Helvetica, sans-serif; font-variant: normal;
                            font-style: normal; text-transform: none; font-weight: bold">左侧树结构（【模块名称】【序号】）</span>
                <a href="../../Public/CommonPage.aspx?table=TAB_SysFunModule">切换到列表视图</a><br />
                        <div class="MenuDetail" id="MenuDetail1" style="background-color: 0099CC; text-align: left; vertical-align: top;">
                            <asp:TreeView ID="TreeViewModule" runat="server" EnableClientScript="true" Width="204px" OnSelectedNodeChanged="TreeViewModule_SelectedNodeChanged">
                            </asp:TreeView>
                        </div>
                    </td>
                </tr>
            </table>
            </div>
            </div>
       </div>
        <div runat="Server" id="detailDiv" visible="false">
        <div id="QueryDiv">
            <table>            
                <tr>
                    <td align="center" style="width: 80px" nowrap>
                        <asp:Label ID="Label1" runat="server" Text="模块名称:"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="TextBox_ModuleName" runat="server" Width="320px" MaxLength="50"></asp:TextBox>
                        <asp:HiddenField ID="ModuleId" runat="server" ></asp:HiddenField>
                    </td>
                </tr>
                <tr>
                    <td align="center" style="height: 20px">
                        <asp:Label ID="Label2" runat="server" Text="父模块:"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="DropDownListFather" runat="server" Width="326px">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <asp:Label ID="Label3" runat="server" Text="顺序:"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="TextBox_ModuleSeq" runat="server" Width="320px" MaxLength="6"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        是否展开节点:</td>
                    <td align="left">
                        <asp:DropDownList ID="DDLIsUnFold" runat="server" Width="326px">
                            <asp:ListItem Value="0">否</asp:ListItem>
                            <asp:ListItem Value="1">是</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                 <tr>
                    <td align="center">
                        <asp:Label ID="Label5" runat="server" Text="链接文件:"></asp:Label>
                    </td>
                    <td> 
                    <input type="file" name="file_UrlFile" style=" width:320px" onpropertychange="return toUrlTextBox();"/>
                    </td>                   
                        </tr>
                        <%--<tr>
                    <td align="center">
                        <asp:Label ID="Label6" runat="server" Text="选择链接文件:"></asp:Label>
                    </td>
                        <td>
                        <asp:FileUpload ID="FileUpload1" runat="server" Width="320px" onpropertychange="toUrlTextBox();"/>
                       </td>
                </tr>--%>
                <tr>
                    <td align="center" style="height: 20px">
                        <asp:Label ID="Label6" runat="server" Text="选择表:"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="DDLCommonPageTab" runat="server" Width="326px" onchange="DDLSelectChange(this);" Enabled="false">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <asp:Label ID="Label4" runat="server" Text="生成的链接:"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="TextBox_Url" runat="server" Width="320px" MaxLength="300" ></asp:TextBox>
                    </td>
                   <%-- <td>
                    <input type="button" id="BtnCreateUrl" class="buttonface" onclick="return WriteUrlEnable();" value="手工输入"/>
                    </td>--%>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <asp:Button ID="Button_Update" runat="server" CssClass="buttonface" OnClick="ButtonUpdate_Click"
                            Text="修改" OnClientClick="return confirm('确认要修改?');" />
                        &nbsp;&nbsp;&nbsp;
                        <asp:Button ID="Button_Delete" runat="server" CssClass="buttonface" Text="删除" OnClick="Button_Delete_Click"
                            OnClientClick="return confirm('确认要删除?');" />
                        &nbsp;&nbsp;&nbsp;
                        <asp:Button ID="Button_Insert" runat="server" CssClass="buttonface" Text="新增" OnClick="Button_Insert_Click" 
                        OnClientClick="return confirm('确认要新增?');"/>
                        &nbsp;&nbsp;&nbsp;
                        <asp:Button ID="Button_Cancel" runat="server" CssClass="buttonface" Text="关闭" OnClick="Button_Cancel_Click" />
                    </td>
                </tr>
                <tr>
                <td align="center" style="height: 20px">
                <asp:Label ID="Label7" runat="server" Text="提示:"></asp:Label>
                </td>
                 <td>
                <asp:Label ID="Label8" runat="server" Text="最后一行建议不要直接编辑,设置“链接文件”和/或“选择<br/>表”自动生成"></asp:Label>
                </td>
                </tr>
            </table>
             </div>
        </div>
    </form>
</body>
</html>
